package com.cincc.cinccimdemo;

import android.app.Application;
import android.content.Context;

import androidx.lifecycle.ViewModelProvider;

import com.cincc.cinccimdemo.common.Constants;
import com.cincc.cinccimdemo.common.HttpUtils;
import com.cincc.cinccimdemo.viewmodel.GlobalViewModel;
import com.tencent.bugly.crashreport.CrashReport;


public class MyApplication extends Application {
    private static final String TAG = "MyApplication";
    public static MyApplication instance = null;
    private GlobalViewModel sequenceViewModel;

    @Override
    public void onCreate() {
        super.onCreate();
        instance = this;
        CrashReport.initCrashReport(getApplicationContext(), "0eceec37ca", true);
        setupIMDirs();
        //忽略证书用 Glide
        HttpUtils.handleSSLHandshake();
        sequenceViewModel = new ViewModelProvider.AndroidViewModelFactory(this).create(GlobalViewModel.class);
    }

    public GlobalViewModel getViewModel() {
        return sequenceViewModel;
    }

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
    }

    private void setupIMDirs() {
        Constants.VIDEO_SAVE_DIR = this.getExternalFilesDir("video").getAbsolutePath() + "/Download/";
        Constants.AUDIO_SAVE_DIR = this.getExternalFilesDir("audio").getAbsolutePath() + "/Download/";
        Constants.PHOTO_SAVE_DIR = this.getExternalFilesDir("photo").getAbsolutePath() + "/Download/";
        Constants.FILE_SAVE_DIR = this.getExternalFilesDir("file").getAbsolutePath() + "/Download/";
    }
}
